package com.zhanbo.zhanbowymusic.main.mine.create;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.mwx.baselib.base.BaseBindingAdapter;
import com.mwx.baselib.base.BaseFragment;
import com.zhanbo.zhanbowymusic.R;
import com.zhanbo.zhanbowymusic.databinding.FragmentCreatePlaylistBinding;
import com.zhanbo.zhanbowymusic.main.bean.CreatePlaylistDetailsEBBean;
import com.zhanbo.zhanbowymusic.main.mine.collections.adapter.PodcastsCollectionsListAdapter;
import com.zhanbo.zhanbowymusic.main.mine.create.adapter.CreatePlayListAdapter;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

/**
 * 我得歌单fragment
 */
public class CreatePlayListFragment extends BaseFragment<FragmentCreatePlaylistBinding> {


    @Override
    protected void init(Bundle savedInstanceState) {
        initView();
        initData();
        initListener();
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);

    }

    @Override
    protected Object getLayout() {
        return R.layout.fragment_create_playlist;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        List<Integer> stringList = new ArrayList<>();
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        stringList.add(1);
        binding.rvCreateList.setLayoutManager(new GridLayoutManager(_mActivity, 4));
        CreatePlayListAdapter adapter = new CreatePlayListAdapter(_mActivity);
        adapter.getItems().addAll(stringList);
        binding.rvCreateList.setAdapter(adapter);
        adapter.setOnItemClickListener(new BaseBindingAdapter.OnItemClickListener<Integer>() {
            @Override
            public void onItemClick(int position) {
                EventBus.getDefault().post(new CreatePlaylistDetailsEBBean());
            }
        });
    }

    @Override
    protected void initListener() {

    }

    public static CreatePlayListFragment newInstance() {

        Bundle args = new Bundle();

        CreatePlayListFragment fragment = new CreatePlayListFragment();
        fragment.setArguments(args);
        return fragment;
    }
}